﻿<?php
// ------------------------------------------------------------------
// NEEDED STUBS FOR THIS EXAMPLE
// ------------------------------------------------------------------


// this will include all needed files to be able to build a Request
include_once($CONF["STUBS_FOLDER"]."Map24MGI/Map24MGI.php5");


// ------------------------------------------------------------------
// NEEDED PARAMETERS FOR THIS REQUEST
// ------------------------------------------------------------------


// coordinates of the location to add
$longitude 	= "514.048";
$latitude 	= "3007.8325";

// symbol used 	to display the location
$symbolId	= "0";

//description
$discription ="Köln";

// zoomlevel
$mapViewClippingWidth = 5000;
$ViewPercentage=20;

//definition of the MGI settings
$ImageWidth = 400;
$ImageHeight = 300;
$MimeType = 'image/gif';

// definition of the imgKey
$imgKey = '123456';

// or use this to get a random Pic ID
// $imgkey=md5(rand(1,809876));

// save key in the Session, to view pic later
$_SESSION['imgKey'] = $imgKey;

// we dont want the bitmapdata as response to this request
$ReplyBitmapData = FALSE;

//definition of the properties

// the first property
$proIdx=0;
$property[$proIdx]= new Property();
$property[$proIdx]->Key='DPI';
$property[$proIdx]->Value='72';
// a second property
$proIdx++;
$property[$proIdx]= new Property();
$property[$proIdx]->Key='xMARGIN';
$property[$proIdx]->Value='100';


// ------------------------------------------------------------------
// BUILDING THE REQUEST
// ------------------------------------------------------------------


// here are all commands defined and are put together in one ArrayOfCommands

// this object will center the map above the new location
$cmdIdx=0;
$commands[$cmdIdx] = new XMLCommandWrapper();
$commands[$cmdIdx]->SetMapView = new SetMapView();
$commands[$cmdIdx]->SetMapView->Coordinate= new Coordinate();
$commands[$cmdIdx]->SetMapView->Coordinate->Longitude = $longitude;
$commands[$cmdIdx]->SetMapView->Coordinate->Latitude = $latitude;
$commands[$cmdIdx]->SetMapView->ClippingWidth = new SetMapViewClippingWidth();
$commands[$cmdIdx]->SetMapView->ClippingWidth->MinimumWidth = $mapViewClippingWidth;
$commands[$cmdIdx]->SetMapView->ViewPercentage = $ViewPercentage;

// definition of the request header with Map24ID and SessionID
$header = new RequestHeader();
$header->Map24ID  = $CONF['MAP24_ID'];
$header->ClientID = $CONF['SESSION_ID'];

// definition of the request body
$request = new RenderImageMapRequest();
$request->MRC = new Map24MRC();
$request->MRC->Commands = $commands;
$request->ImageKey = $imgKey;
$request->ReplyBitmapData = $ReplyBitmapData;
$request->BitmapDescriptor = new BitmapDescriptor();
$request->BitmapDescriptor->ImageWidth = $ImageWidth;
$request->BitmapDescriptor->ImageHeight = $ImageHeight;
$request->BitmapDescriptor->MimeType = $MimeType;
$request->BitmapDescriptor->Properties = $property;


// ------------------------------------------------------------------
// EXECUTE THE REQUEST
// ------------------------------------------------------------------


// in this object the SoapClient will be initiated and executed
$mgi = new Map24MGI($CONF['MAPTP_SYSTEM'],$CONF['MAP24_ID'],$CONF['SESSION_ID']);
$response = $mgi->renderImageMap($header,$request);


// ------------------------------------------------------------------
// OUTPUT THE RESULT
// ------------------------------------------------------------------

if(isset($response->ImageMap) )
{
	$resultString = "<a href=\"code_source.php?sid=" . $CONF['SESSION_ID'] ."&src=Map24MGI_getbufferedimage.php5\" target=\"codeframe\">GetBufferedImage</a>";
}
else
{
	$resultString = "Sorry, no answer from the webservices";
}


?>